const set = words => words.reduce((obj, word) => ({ ...obj, [word]: true }), {});

export default {
  name: 'sql',

  atoms: set(['null']),

  dateSQL: set(['date', 'datetime']),

  operatorChars: /^[*+\-%<>!=&|^/#@?~]/,

  keywords: set([
    'create',
    'database',
    'table',
    'view',
    'as',
    'attach',
    'drop',
    'detach',
    'rename',
    'alter',
    'show',
    'databases',
    'tables',
    'processlist',
    'describe',
    'exists',
    'use',
    'set',
    'optimize',
    'insert',
    'into',
    'select',
    'from',
    'sample',
    'array',
    'join',
    'where',
    'prewhere',
    'group',
    'by',
    'with',
    'totals',
    'having',
    'order',
    'distinct',
    'limit',
    'union',
    'all',
    'format',
    'in',
    'engine',
    'kill',
    'query'
  ]),

  builtin: set([
    'plus',
    'minus',
    'multiply',
    'divide',
    'intDiv',
    'intDivOrZero',
    'modulo',
    'negate',
    'abs',
    'bitAnd',
    'bitOr',
    'bitXor',
    'bitNot',
    'bitShiftLeft',
    'bitShiftRight',
    'equals',
    'notEquals',
    'less',
    'greater',
    'lessOrEquals',
    'greaterOrEquals',
    'and',
    'or',
    'not',
    'xor',
    'toUInt8',
    'toUInt16',
    'toUInt32',
    'toUInt64',
    'toInt8',
    'toInt16',
    'toInt32',
    'toInt64',
    'toFloat32',
    'toFloat64',
    'toUInt8OrZero',
    'toUInt16OrZero',
    'toUInt32OrZero',
    'toUInt64OrZero',
    'toInt8OrZero',
    'toInt16OrZero',
    'toInt32OrZero',
    'toInt64OrZero',
    'toFloat32OrZero',
    'toFloat64OrZero',
    'toDecimal32',
    'toDecimal64',
    'toDecimal128',
    'toDate',
    'toDateTime',
    'toString',
    'toFixedString',
    'toStringCutToZero',
    'reinterpretAsUInt8',
    'reinterpretAsUInt16',
    'reinterpretAsUInt32',
    'reinterpretAsUInt64',
    'reinterpretAsInt8',
    'reinterpretAsInt16',
    'reinterpretAsInt32',
    'reinterpretAsInt64',
    'reinterpretAsFloat32',
    'reinterpretAsFloat64',
    'reinterpretAsDate',
    'reinterpretAsDateTime',
    'reinterpretAsString',
    'toYear',
    'toMonth',
    'toDayOfMonth',
    'toDayOfWeek',
    'toHour',
    'toMinute',
    'toSecond',
    'toMonday',
    'toStartOfMonth',
    'toStartOfQuarter',
    'toStartOfYear',
    'toStartOfDay',
    'toStartOfHour',
    'toStartOfMinute',
    'toStartOfFiveMinute',
    'toStartOfFifteenMinutes',
    'toTime',
    'toRelativeYearNum',
    'toRelativeMonthNum',
    'toRelativeWeekNum',
    'toRelativeDayNum',
    'toRelativeHourNum',
    'toRelativeMinuteNum',
    'toRelativeSecondNum',
    'now',
    'today',
    'yesterday',
    'timeSlot',
    'timeSlots',
    'formatDateTime',
    'empty',
    'notEmpty',
    'length',
    'lengthUTF8',
    'lower',
    'upper',
    'lowerUTF8',
    'upperUTF8',
    'reverse',
    'reverseUTF8',
    'concat',
    'substring',
    'substringUTF8',
    'appendTrailingCharIfAbsent',
    'convertCharset',
    'base64Encode',
    'base64Decode',
    'tryBase64Decode',
    'position',
    'positionUTF8',
    'match',
    'extract',
    'extractAll',
    'like',
    'notLike',
    'replaceOne',
    'replaceAll',
    'replaceRegexpOne',
    'replaceRegexpAll',
    'emptyArrayUInt8',
    'emptyArrayUInt16',
    'emptyArrayUInt32',
    'emptyArrayUInt64',
    'emptyArrayInt8',
    'emptyArrayInt16',
    'emptyArrayInt32',
    'emptyArrayInt64',
    'emptyArrayFloat32',
    'emptyArrayFloat64',
    'emptyArrayDate',
    'emptyArrayDateTime',
    'emptyArrayString',
    'emptyArrayToSingle',
    'range',
    'array',
    'arrayConcat',
    'arrayElement',
    'has',
    'hasAll',
    'hasAny',
    'indexOf',
    'countEqual',
    'arrayEnumerate',
    'arrayEnumerateUniq',
    'arrayJoin',
    'arrayPopBack',
    'arrayPopFront',
    'arrayPushBack',
    'arrayPushFront',
    'arrayResize',
    'arraySlice',
    'arrayUniq',
    'operator',
    'arrayMap',
    'arrayFilter',
    'arrayCount',
    'arrayExists',
    'arrayAll',
    'arraySum',
    'arrayCumSum',
    'arraySort',
    'arrayReverseSort',
    'arrayFirst',
    'arrayFirstIndex',
    'splitByChar',
    'splitByString',
    'arrayStringConcat',
    'alphaTokens',
    'protocol',
    'domain',
    'domainWithoutWWW',
    'topLevelDomain',
    'firstSignificantSubdomain',
    'cutToFirstSignificantSubdomain',
    'path',
    'pathFull',
    'queryString',
    'fragment',
    'queryStringAndFragment',
    'extractURLParameter',
    'extractURLParameters',
    'extractURLParameterNames',
    'URLHierarchy',
    'URLPathHierarchy',
    'decodeURLComponent',
    'cutWWW',
    'cutQueryString',
    'cutFragment',
    'cutQueryStringAndFragment',
    'cutURLParameter',
    'IPv4NumToString',
    'IPv4StringToNum',
    'IPv4NumToStringClassC',
    'IPv6NumToString',
    'IPv6StringToNum',
    'rand',
    'rand64',
    'halfMD5',
    'MD5',
    'sipHash64',
    'sipHash128',
    'cityHash64',
    'intHash32',
    'intHash64',
    'SHA224',
    'SHA256',
    'URLHash',
    'hex',
    'unhex',
    'UUIDStringToNum',
    'UUIDNumToString',
    'bitmaskToList',
    'bitmaskToArray',
    'floor',
    'ceil',
    'round',
    'roundToExp2',
    'roundDuration',
    'roundAge',
    'if',
    'multiIf',
    'e',
    'pi',
    'exp',
    'log',
    'exp2',
    'log2',
    'exp10',
    'log10',
    'sqrt',
    'cbrt',
    'erf',
    'erfc',
    'lgamma',
    'tgamma',
    'sin',
    'cos',
    'tan',
    'asin',
    'acos',
    'atan',
    'pow',
    'regionToCity',
    'regionToArea',
    'regionToDistrict',
    'regionToCountry',
    'regionToContinent',
    'regionToPopulation',
    'regionIn',
    'regionHierarchy',
    'regionToName',
    'greatCircleDistance',
    'pointInEllipses',
    'pointInPolygon',
    'OSIn',
    'SEIn',
    'dictGetUInt8',
    'dictGetUInt16',
    'dictGetUInt32',
    'dictGetUInt64',
    'dictGetInt8',
    'dictGetInt16',
    'dictGetInt32',
    'dictGetInt64',
    'dictGetFloat32',
    'dictGetFloat64',
    'dictGetDate',
    'dictGetDateTime',
    'dictGetString',
    'dictGetUUID',
    'dictGetTOrDefault',
    'dictIsIn',
    'dictGetHierarchy',
    'dictHas',
    'visitParamHas',
    'visitParamExtractUInt',
    'visitParamExtractInt',
    'visitParamExtractFloat',
    'visitParamExtractBool',
    'visitParamExtractRaw',
    'visitParamExtractString',
    'in',
    'tuple',
    'tupleElement',
    'hostName',
    'visibleWidth',
    'toTypeName',
    'blockSize',
    'materialize',
    'ignore',
    'sleep',
    'currentDatabase',
    'hasColumnInTable',
    'formatReadableSize',
    'isFinite',
    'isInfinite',
    'isNaN',
    'isNull',
    'isNotNull',
    'coalesce',
    'ifNull',
    'nullIf',
    'assumeNotNull',
    'toNullable',
    'bar',
    'transform',
    'notIn',
    'least',
    'greatest',
    'uptime',
    'version',
    'rowNumberInAllBlocks',
    'runningDifference',
    'MACNumToString',
    'MACStringToNum',
    'MACStringToOUI',
    'getSizeOfEnumType',
    'toColumnTypeName',
    'dumpColumnStructure',
    'defaultValueOfArgumentType',
    'indexHint',
    'replicate',
    'globalIn',
    'globalNotIn',
    'lambda',
    'count',
    'any',
    'anyHeavy',
    'anyLast',
    'groupBitAnd',
    'groupBitOr',
    'groupBitXor',
    'min',
    'max',
    'argMin',
    'argMax',
    'sum',
    'sumWithOverflow',
    'sumMap',
    'avg',
    'uniq',
    'uniqHLL12',
    'uniqExact',
    'uniqCombined',
    'groupArray',
    'groupArrayInsertAt',
    'groupUniqArray',
    'median',
    'medianTiming',
    'medianDeterministic',
    'medianTimingWeighted',
    'varSamp',
    'varPop',
    'stddevSamp',
    'stddevPop',
    'covarSamp',
    'covarPop',
    'topK',
    'corr',
    'quantile',
    'quantiles',
    'quantileTiming',
    'quantilesTiming',
    'quantileTimingWeighted',
    'quantilesTimingWeighted',
    'quantileDeterministic',
    'quantilesDeterministic',
    'quantileExact',
    'quantileExactWeighted',
    'quantileTDigest',
    'sequenceMatch',
    'sequenceCount',
    'windowFunnel',
    'retention',
    'uniqUpTo',
    'countIf',
    'anyIf',
    'anyLastIf',
    'minIf',
    'maxIf',
    'argMinIf',
    'argMaxIf',
    'sumIf',
    'avgIf',
    'uniqIf',
    'uniqHLL12If',
    'uniqExactIf',
    'groupArrayIf',
    'groupUniqArrayIf',
    'medianIf',
    'medianTimingIf',
    'medianDeterministicIf',
    'medianTimingWeightedIf',
    'varSampIf',
    'varPopIf',
    'stddevSampIf',
    'stddevPopIf',
    'covarSampIf',
    'covarPopIf',
    'corrIf',
    'quantileIf',
    'quantilesIf',
    'quantileTimingIf',
    'quantilesTimingIf',
    'quantileTimingWeightedIf',
    'quantilesTimingWeightedIf',
    'quantileDeterministicIf',
    'quantilesDeterministicIf',
    'sequenceMatchIf',
    'uniqUpToIf',
    'countArray',
    'anyArray',
    'anyLastArray',
    'minArray',
    'maxArray',
    'argMinArray',
    'argMaxArray',
    'sumArray',
    'avgArray',
    'uniqArray',
    'uniqHLL12Array',
    'uniqExactArray',
    'groupArrayArray',
    'groupUniqArrayArray',
    'medianArray',
    'medianTimingArray',
    'medianDeterministicArray',
    'medianTimingWeightedArray',
    'varSampArray',
    'varPopArray',
    'stddevSampArray',
    'stddevPopArray',
    'covarSampArray',
    'covarPopArray',
    'corrArray',
    'quantileArray',
    'quantilesArray',
    'quantileTimingArray',
    'quantilesTimingArray',
    'quantileTimingWeightedArray',
    'quantilesTimingWeightedArray',
    'quantileDeterministicArray',
    'quantilesDeterministicArray',
    'sequenceMatchArray',
    'uniqUpToArray',
    'countState',
    'anyState',
    'anyLastState',
    'minState',
    'maxState',
    'argMinState',
    'argMaxState',
    'sumState',
    'avgState',
    'uniqState',
    'uniqHLL12State',
    'uniqExactState',
    'groupArrayState',
    'groupUniqArrayState',
    'medianState',
    'medianTimingState',
    'medianDeterministicState',
    'medianTimingWeightedState',
    'varSampState',
    'varPopState',
    'stddevSampState',
    'stddevPopState',
    'covarSampState',
    'covarPopState',
    'corrState',
    'quantileState',
    'quantilesState',
    'quantileTimingState',
    'quantilesTimingState',
    'quantileTimingWeightedState',
    'quantilesTimingWeightedState',
    'quantileDeterministicState',
    'quantilesDeterministicState',
    'sequenceMatchState',
    'uniqUpToState',
    'countMerge',
    'anyMerge',
    'anyLastMerge',
    'minMerge',
    'maxMerge',
    'argMinMerge',
    'argMaxMerge',
    'sumMerge',
    'avgMerge',
    'uniqMerge',
    'uniqHLL12Merge',
    'uniqExactMerge',
    'groupArrayMerge',
    'groupUniqArrayMerge',
    'medianMerge',
    'medianTimingMerge',
    'medianDeterministicMerge',
    'medianTimingWeightedMerge',
    'varSampMerge',
    'varPopMerge',
    'stddevSampMerge',
    'stddevPopMerge',
    'covarSampMerge',
    'covarPopMerge',
    'corrMerge',
    'quantileMerge',
    'quantilesMerge',
    'quantileTimingMerge',
    'quantilesTimingMerge',
    'quantileTimingWeightedMerge',
    'quantilesTimingWeightedMerge',
    'quantileDeterministicMerge',
    'quantilesDeterministicMerge',
    'sequenceMatchMerge',
    'uniqUpToMerge',
    'file',
    'merge',
    'numbers',
    'remote',
    'url',
    'jdbc'
  ])
};